<?php
/**
 * Created by PhpStorm.
 * User: w-pc
 * Date: 2017/03/07
 * Time: 20:16
 */
namespace Common\Model;
use Think\Model;

class IndexModel extends Model{
    private $_db = '';

    public function __construct() {
        $this->_db = M('index');
    }
    public function get_info_num(){
//        $info = array(array('log'=>array('name'=>'日志数','icon'=>'gears','num'=>0,'now'=>0)),
//                      array('article'=>array('name'=>'文章数量','icon'=>'navicon','num'=>0,'now'=>0)),
//                      array('diary'=>array('name'=>'随记数量','icon'=>'pencil-square','num'=>0,'now'=>0)),
//                      array('photo'=>array('name'=>'相册数量','icon'=>'photo','num'=>0,'now'=>0)),
//                      array('message'=>array('name'=>'留言数','icon'=>'comment','num'=>0,'now'=>0)),
//                      array('visit'=>array('name'=>'访问量','icon'=>'eye','num'=>0,'now'=>0)));
        $info = array(array('name'=>'日志数','icon'=>'gears','num'=>0,'now'=>0),
            array('name'=>'文章数量','icon'=>'navicon','num'=>0,'now'=>0),
            array('name'=>'随记数量','icon'=>'pencil-square','num'=>0,'now'=>0),
            array('name'=>'相册数量','icon'=>'photo','num'=>0,'now'=>0),
            array('name'=>'留言数','icon'=>'comment','num'=>0,'now'=>0),
            array('name'=>'访问量','icon'=>'eye','num'=>0,'now'=>0));
        return $info;
    }
    public function get_ArticleList(){
        $a_db = new ArticleModel();
        $article_list = $a_db->getArticleByList();
        $i = 0;
        $list = array();
        foreach ($article_list as $item) {
            $list[$i] = $item;
            $i++;
            if($i>=6) break;
        }
        return $article_list;
    }
    public function add_Info($index_arr){
        $this->_db->where(array('i_id'=>1))->save($index_arr);
    }
    public function get_Info(){
        $index_arr = $this->_db->where(array('i_id'=>1))->find();
        return $index_arr;
    }
}